# SPDX-License-Identifier: Apache-2.0

# zephyr-keep-sorted-start
add_subdirectory(adi)
add_subdirectory(ams)
add_subdirectory(aosong)
add_subdirectory(asahi_kasei)
add_subdirectory(bosch)
add_subdirectory(broadcom)
add_subdirectory(espressif)
add_subdirectory(everlight)
add_subdirectory(honeywell)
add_subdirectory(infineon)
add_subdirectory(ite)
add_subdirectory(jedec)
add_subdirectory(liteon)
add_subdirectory(maxim)
add_subdirectory(meas)
add_subdirectory(melexis)
add_subdirectory(memsic)
add_subdirectory(microchip)
add_subdirectory(nordic)
add_subdirectory(nuvoton)
add_subdirectory(nxp)
add_subdirectory(pixart)
add_subdirectory(pni)
add_subdirectory(realtek)
add_subdirectory(renesas)
add_subdirectory(rohm)
add_subdirectory(seeed)
add_subdirectory(sensirion)
add_subdirectory(silabs)
add_subdirectory(st)
add_subdirectory(tdk)
add_subdirectory(ti)
add_subdirectory(vishay)
add_subdirectory(wsen)
# zephyr-keep-sorted-stop

add_subdirectory_ifdef(CONFIG_A01NYUB a01nyub)
add_subdirectory_ifdef(CONFIG_AMD_SB_TSI amd_sb_tsi)
add_subdirectory_ifdef(CONFIG_AMG88XX amg88xx)
add_subdirectory_ifdef(CONFIG_APDS9253 apds9253)
add_subdirectory_ifdef(CONFIG_APDS9960 apds9960)
add_subdirectory_ifdef(CONFIG_APDS9306 apds9306)
add_subdirectory_ifdef(CONFIG_CURRENT_AMP current_amp)
add_subdirectory_ifdef(CONFIG_ENS160 ens160)
add_subdirectory_ifdef(CONFIG_EXPLORIR_M explorir_m)
add_subdirectory_ifdef(CONFIG_F75303 f75303)
add_subdirectory_ifdef(CONFIG_FCX_MLDX5 fcx_mldx5)
add_subdirectory_ifdef(CONFIG_GROW_R502A grow_r502a)
add_subdirectory_ifdef(CONFIG_HC_SR04 hc_sr04)
add_subdirectory_ifdef(CONFIG_HP206C hp206c)
add_subdirectory_ifdef(CONFIG_IST8310 ist8310)
add_subdirectory_ifdef(CONFIG_LM35 lm35)
add_subdirectory_ifdef(CONFIG_LM75 lm75)
add_subdirectory_ifdef(CONFIG_LM77 lm77)
add_subdirectory_ifdef(CONFIG_MHZ19B mhz19b)
add_subdirectory_ifdef(CONFIG_NCT75 nct75)
add_subdirectory_ifdef(CONFIG_NTC_THERMISTOR ntc_thermistor)
add_subdirectory_ifdef(CONFIG_PMS7003 pms7003)
add_subdirectory_ifdef(CONFIG_PZEM004T pzem004t)
add_subdirectory_ifdef(CONFIG_QDEC_SAM qdec_sam)
add_subdirectory_ifdef(CONFIG_RPI_PICO_TEMP rpi_pico_temp)
add_subdirectory_ifdef(CONFIG_S11059 s11059)
add_subdirectory_ifdef(CONFIG_SBS_GAUGE sbs_gauge)
add_subdirectory_ifdef(CONFIG_SX9500 sx9500)
add_subdirectory_ifdef(CONFIG_TH02 th02)
add_subdirectory_ifdef(CONFIG_TSIC_XX6 tsic_xx6)
add_subdirectory_ifdef(CONFIG_VEAA_X_3 veaa_x_3)
add_subdirectory_ifdef(CONFIG_VOLTAGE_DIVIDER voltage_divider)
add_subdirectory_ifdef(CONFIG_XBR818 xbr818)
add_subdirectory_ifdef(CONFIG_TACH_ENE_KB1200 ene_tach_kb1200)
add_subdirectory_ifdef(CONFIG_MB7040 mb7040)

zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/sensor.h)

zephyr_library()
zephyr_library_property(ALLOW_EMPTY TRUE)

zephyr_library_sources_ifdef(CONFIG_USERSPACE sensor_handlers.c)
zephyr_library_sources_ifdef(CONFIG_SENSOR_SHELL sensor_shell.c)
zephyr_library_sources_ifdef(CONFIG_SENSOR_SHELL_STREAM sensor_shell_stream.c)
zephyr_library_sources_ifdef(CONFIG_SENSOR_SHELL_BATTERY shell_battery.c)
zephyr_library_sources_ifdef(CONFIG_SENSOR_ASYNC_API sensor_decoders_init.c default_rtio_sensor.c)

dt_has_chosen(has_zephyr_sensor_clock PROPERTY "zephyr,sensor-clock")

if(CONFIG_SENSOR_CLOCK_RTC OR CONFIG_SENSOR_CLOCK_COUNTER)
  if(has_zephyr_sensor_clock)
    zephyr_library_sources(sensor_clock_external.c)
  else()
    message(FATAL_ERROR "Sensor clock type (RTC or Counter) is selected, but no zephyr,sensor-clock is defined in the device tree.")
  endif()
elseif(CONFIG_SENSOR_CLOCK_SYSTEM)
  zephyr_library_sources(sensor_clock_sys.c)
endif()
